import request from '@/utils/request';

export async function getProductManufactInforExecuteByPage(params: any) {
  return request('/api/product/getProductManufactInforExecuteByPage', {
    method: 'POST',
    data: params,
  });
}

/**开始工序执行 */
export async function startProductManufactExec(params: any) {
  return request('/api/product/startProductManufactExec', {
    method: 'POST',
    params: {
      productManufactInforId: params,
    },
  });
}

/**暂停执行工序 */
export async function pauseProductManufactExec(params: any) {
  return request('/api/product/pauseProductManufactExec', {
    method: 'POST',
    params: {
      productManufactInforId: params,
    },
  });
}

/**完成工序 */
export async function finishProductManufactExec(params: any) {
  return request('/api/product/finishProductManufactExec', {
    method: 'POST',
    params: {
      productManufactInforId: params,
    },
  });
}

/**计时开始 */
export async function startTiming(params: any) {
  return request('/api/product/startTiming', {
    method: 'POST',
    params: {
      productManufactInforId: params,
    },
  });
}

/**计时结束 */
export async function pauseTiming(params: any) {
  return request('/api/product/pauseTiming', {
    method: 'POST',
    params: {
      productManufactInforId: params,
    },
  });
}

/**获取BOM清单 /api/product/getBomOverview*/
export async function getBomOverview(params: any) {
  return request('/api/product/getBomOverview', {
    method: 'POST',
    params: {
      workOrderInfoId: params,
    },
  });
}

//获取图纸
export async function getDrawingInfo(params: any) {
  return request('/api/product/getDrawingInfo', {
    method: 'POST',
    params: {
      workOrderInfoId: params,
    },
  });
}
//获取该工单的生产进度
export async function getManufactInfo(params: any) {
  return request('/api/product/getManufactInfo', {
    method: 'POST',
    params: {
      workOrderInfoId: params,
    },
  });
}

//自检上传/api/quality/getInspectionTaskByProcessId
export async function getInspectionTaskByProcessId(params: any) {
  return request('/api/quality/getInspectionTaskByProcessId', {
    method: 'POST',
    params: {
      processId: params,
    },
  });
}
//获取当前计时总量和最后一次计时开始时间
export async function getSumTimingAndCurStartTime(params: any) {
  return request('/api/product/getSumTimingAndCurStartTime', {
    method: 'POST',
    params: {
      processId: params,
    },
  });
}

export async function addProductManufactInforExecute(params: any) {
  return request('/api/product/addProductManufactInforExecute', {
    method: 'POST',
    data: params,
  });
}

export async function updateProductManufactInforExecute(params: any) {
  return request('/api/product/updateProductManufactInforExecute', {
    method: 'POST',
    data: params,
  });
}

export async function delProductManufactInforExecute(params: any) {
  return request('/api/product/delProductManufactInforExecute', {
    method: 'POST',
    data: params,
  });
}

export async function exportProductManufactInforExecute(params: any) {
  return request('/api/product/exportProductManufactInforExecute', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

// 获取生产工序（任务）
export async function getProductManufactExecInfosByWoId(params: any) {
  return request('/api/product/getProductManufactExecInfosByWoId', {
    method: 'POST',
    params: {
      woId: params,
    },
  });
}

// 工时补录
export async function addWorkHoursRequest(params: any) {
  return request('/api/product/addWorkHoursRequest', {
    method: 'POST',
    data: params,
  });
}

// 获取当前用户名
export async function viewBaseInfo(params: any) {
  return request('/api/user/viewBaseInfo', {
    method: 'POST',
    data: params,
  });
}

// 获取生产经理姓名
export async function getTeamManufactManager(params: any) {
  return request('/api/product/getTeamManufactManager', {
    method: 'POST',
    params: {
      workOrderInfoId: params,
    },
  });
}
// 获取团队成员
export async function getTeamMember(params: any) {
  return request('/api/product/getTeamMember', {
    method: 'POST',
    params: {
      workOrderInfoId: params,
    },
  });
}

// 获取异常优先级
export async function getAllErrorPriority(params: any) {
  return request('/api/product/getAllErrorPriority', {
    method: 'POST',
    data: params,
  });
}

// 获取异常类型
export async function getAllErrorType(params: any) {
  return request('/api/product/getAllErrorType', {
    method: 'POST',
    data: params,
  });
}

// 异常填报
export async function addErrorReport(params: any) {
  return request('/api/product/addErrorReport', {
    method: 'POST',
    data: params,
  });
}

// 异常填报新增附件
export async function addErrorReport2(para: any) {
  return request('/api/product/addErrorReport2', {
    method: 'POST',
    requestType: 'form',
    data: para.file,
    params: {
      Wo: para.Wo,
      deadLine: para.deadLine,
      errorDes: para.errorDes,
      errorType: para.errorType,
      handlingMan: para.handlingMan,
      operator: para.operator,
      priority: para.priority,
      taskId: para.taskId,
      workOrderInforId: para.workOrderInforId,
      projectName: para.projectName,
      workHour: para.workHour,
    },
  });
}

// 获取异常列表
export async function getErrorReportByPage(params: any) {
  return request('/api/product/getErrorReportByPage', {
    method: 'POST',
    data: params,
  });
}
export async function getErrorReportByPageAndWo(params: any) {
  return request('/api/product/getErrorReportByPageAndWo', {
    method: 'POST',
    data: params,
  });
}

// 异常处理
export async function updateErrorReport(params: any) {
  return request('/api/product/updateErrorReport', {
    method: 'POST',
    data: params,
  });
}
export async function deliverErrorReport(params: any) {
  return request('/api/product/deliverErrorReport', {
    method: 'POST',
    data: params,
  });
}

// 获取审核信息
export async function getWorkHoursRequestHstByPageAndTaskId(params: any) {
  return request('/api/product/getWorkHoursRequestHstByPageAndTaskId', {
    method: 'POST',
    data: params,
  });
}

// 获取自检清单
export async function getInspectionTemplateByProductTypeAndTypeAndName(para: any) {
  return request('/api/quality/getInspectionTemplateByProductTypeAndTypeAndName', {
    method: 'POST',
    data: para,
    params: {
      name: para.name,
      productType: para.productType,
      type: para.type,
    },
  });
}

// 获取工单信息
export async function getWorkOrderInforByWo(params: any) {
  return request('/api/product/getWorkOrderInforByWo', {
    method: 'POST',
    params: {
      wo: params,
    },
  });
}

//获取状态/api/product/getProductManufactStateById
export async function getProductManufactStateById(params: any) {
  return request('/api/product/getProductManufactStateById', {
    method: 'POST',
    params: {
      productManufactInforId: params,
    },
  });
}

//获取自检清单/api/quality/getInspectionTaskValueByProcessId
export async function getInspectionTaskValueByProcessId(params: any) {
  return request('/api/quality/getInspectionTaskValueByProcessId', {
    method: 'POST',
    params: {
      processId: params,
    },
  });
}

//提交检验单/api/quality/submitInspectionTask
export async function submitInspectionTask(params: any) {
  return request('/api/quality/submitInspectionTask', {
    method: 'POST',
    data: params,
  });
}

//暂存自检清单/api/quality/stagingInspectionTask
export async function stagingInspectionTask(params: any) {
  return request('/api/quality/stagingInspectionTask', {
    method: 'POST',
    data: params,
  });
}

//获取图纸列表的pdf和图片的预览路径
export async function getDrawingPreviewUrl(params: any) {
  return request('/api/product/getDrawingPreviewUrl', {
    method: 'POST',
    params: {
      productDrawingInfoId: params,
    },
  });
}

export default {
  getProductManufactInforExecuteByPage,
  addProductManufactInforExecute,
  updateProductManufactInforExecute,
  delProductManufactInforExecute,
  exportProductManufactInforExecute,
  getSumTimingAndCurStartTime,
  getDrawingPreviewUrl,
  startTiming,
};
